package com.harassment.interception.ui.fragments.interceptRecord.smsFragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.harassment.interception.R;
import com.harassment.interception.interception.sms.SmsInterception;
import com.harassment.interception.ui.activities.main.MainActivity;
import com.harassment.interception.ui.fragments.bottomFragment.BottomBar;
import com.harassment.interception.ui.fragments.interceptRecord.phoneFragment.PhoneListAdapter;

public class SmsFragment extends Fragment {
    private static final String TAG = "SmsFragment";
    private RecyclerView mRecyclerView;
    private SmsListAdapter mSmsListAdapter;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (mSmsListAdapter == null) {
            MainActivity mainActivity = (MainActivity) getActivity();
            BottomBar bottomBar = mainActivity.getBottomBar();
            mSmsListAdapter = new SmsListAdapter(bottomBar,this);
        }
    }

    @Override
    public void onStart() {
        super.onStart();
        if (mRecyclerView == null) {
            mRecyclerView = getView().findViewById(R.id.base_recycler_view);
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
            mRecyclerView.setLayoutManager(linearLayoutManager);
            mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),DividerItemDecoration.VERTICAL));
            mRecyclerView.setAdapter(mSmsListAdapter);
            SmsInterception.setLinearLayoutManager(linearLayoutManager);
            SmsInterception.setSmsListAdapter(mSmsListAdapter);
        }
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.base_recycler_view, container, false);
        return view;
    }

}
